package com.synyi.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.synyi.domain.Donor;
import com.synyi.entity.DonorEntity;
import com.synyi.entity.DonorSelectEntity;
import com.synyi.entity.Result;
import com.synyi.service.DonorService;
import com.synyi.mapper.DonorMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

/**
* @author zhao
* @description 针对表【donor】的数据库操作Service实现
* @createDate 2024-04-09 15:37:17
*/
@Service
public class DonorServiceImpl extends ServiceImpl<DonorMapper, Donor>
    implements DonorService{

    /**
     * 添加供体信息
     * @param donorEntity
     * @return
     */
    @Transactional
    @Override
    public Result addDonor(DonorEntity donorEntity) {
        Donor donor = new Donor();
        BeanUtils.copyProperties(donorEntity, donor);
        donor.setId(Long.valueOf(new BCryptPasswordEncoder().encode(System.currentTimeMillis() + "health")));
        donor.setCreateTime(new Date());
        donor.setIdCard(new BCryptPasswordEncoder().encode(donor.getIdCard() + "health"));
        return Result.end(200, donor, "");
    }

    @Override
    public Result updateDonor(DonorEntity donorEntity) {
        return null;
    }

    @Override
    public Result deleteDonorById(Long id) {
        return null;
    }

    @Override
    public Result selectDonor(DonorSelectEntity donorSelectEntity) {
        return null;
    }
}




